package com.znsd.zl.app.customize.dao;

import com.znsd.zl.app.customize.entity.CustomizeEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * @ClassName TCustomize
 * @Description 描述
 * @author zhangzhou
 * @email jaypdd@163.com
 * @date 2020-08-30 15:42:52
 * @Version v1.0
 */
@Mapper
public interface CustomizeDao extends BaseMapper<CustomizeEntity> {

	/**
	 * 将定制状态改为已定制
	 * @param id
	 */
	@Update("update t_customize set `status`=1 where ID=#{id}")
	void setStatusSuccess(Integer id);

	/**
	 * 根据用户名将定制状态改为取消
	 * @param name
	 */
	@Update("update t_customize set `status`=2 where user_name=#{name}and`status`=0 and is_delete=0")
	void setStatusCancel(String name);

	/**
	 * 根据名字查询
	 * @param name
	 * @return
	 */
	@Select("select * from t_customize where user_name=#{name} and is_delete=0")
	CustomizeEntity findByName(String name);

	/**
	 * 删除
	 * @param id
	 */
	@Select("update t_customize set is_delete=1 where id=#{id}")
	void isDelete(Integer id);

}
